package com.sincebest.fivestar.rest;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sincebest.fivestar.common.ResultResponse;
import com.sincebest.fivestar.model.GameResult;
import com.sincebest.fivestar.service.GameService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * Created by peter on 17/3/28
 */
@Api(value = "game", description = "游戏服务接口")
@RestController
@RequestMapping(value="/game", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class GameController extends BaseController{

    
    @Autowired
    private GameService gameService;
    
	@RequestMapping(value = "/notify-game-result", method = RequestMethod.POST)
	@ApiOperation(value = "通知游戏结果")
	public ResultResponse<Boolean> notifyGameResult(HttpServletRequest request, @ApiParam(value = "游戏结果") @RequestBody GameResult result)
	{
		gameService.notifyGameResult(result);
		return ResultResponse.ok(true);
    }
	
	@RequestMapping(value = "/game-invite", method = RequestMethod.POST)
	@ApiOperation(value = "游戏邀请")
	public ResultResponse<Boolean> gameInvite(HttpServletRequest request, @ApiParam(value = "麻将馆id") @RequestParam String houseId,
			@ApiParam(value = "邀请链接") @RequestParam String inviteUrl)
	{
		boolean result = gameService.gameInvite(houseId, inviteUrl);
		
		return ResultResponse.ok(result);
    }
	
}
